﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using MicropleSoft.Controls;
using MicropleSoft.Controls.ComplexControl;
using MicropleSoft.WmsApp.Base.Business;

namespace MicropleSoft.WmsApp.PurchaseOrder
{
    public partial class PurchaseOrderEditor : DataBinderPanelBase
    {
        public PurchaseOrderEditor()
        {
            InitializeComponent();
            this.cGridLookUpEdit1.LookUpEditValueChanged += CGridLookUpEdit1_LookUpEditValueChanged;
            this.cGridLookUpEdit2.LookUpEditValueChanged += CGridLookUpEdit2_LookUpEditValueChanged;
        }

        private void CGridLookUpEdit1_LookUpEditValueChanged(DataRowView dataRow)
        {
            foreach (Control control in this.xtraTabPage2.Controls)
            {
                var baseComplexControl = (CBaseComplexControl) control;
                if (!String.IsNullOrEmpty(baseComplexControl.ExtendText))
                {
                    if(dataRow.DataView.Table.Columns.Contains(baseComplexControl.ExtendText))
                    {
                        ((IComplexDataBinder) baseComplexControl).EditValue = dataRow[baseComplexControl.ExtendText];
                    }
                }
            }
            //throw new NotImplementedException();
        }

        private void CGridLookUpEdit2_LookUpEditValueChanged(DataRowView dataRow)
        {
            //throw new NotImplementedException();
        }
   
    }
}
